Repository navigation
Stop rdann and Annotation.apply_range before sampto - #667
Merged
Merged
Conversation
rdann and apply_range included an annotation at sample sampto, while rdrecord and rdsamp return the samples before it. Annotations read with the same range as a signal could therefore be one sample past its end, and indexing the signal with them raised an IndexError. Return the annotations before sampto, as rdrecord does. Fixes #470.
tompollard
commented
Nov 23, 2026
tompollard
left a comment
Member
Author
There was a problem hiding this comment.
Reviewed e264759. The exclusive sampto boundary is applied consistently in rdann and Annotation.apply_range, matching rdrecord and rdsamp. I found no actionable issues. All 40 focused offline annotation tests and all 18 PR checks pass. Looks good to merge from my review.
tompollard
added a commit
that referenced
this pull request
Nov 24, 2026
## Summary Bump the version from 5.1.0 to 5.2.0, and collect the 19 entries in `changelog.d/` into `docs/changes.rst` with `towncrier build --date "Nov 2026"`, with a short summary at the top of the new section. This is a minor release. The one change that existing code may notice is that `rdann` and `Annotation.apply_range` now stop before `sampto`, as `rdrecord` and `rdsamp` do, so an annotation exactly at `sampto` is no longer included (#667). The summary calls it out, with how to get the old result. The release also includes: - **Fixes for PhysioNet:** `get_dbs`, which PhysioNet's API change had broken (#665), record names with folders in `pn_dir` (#666), and `physionet://` and other URIs in `read_edf`, `rdedfann` and `read_wav` (#674). - **Robustness:** - headers whose base time or date is in another form (#668); - multi-segment writes that leave no partial record after an error (#673); - a warning before `wrsamp` replaces another record's signal files (#675). - **New:** a beat-by-beat comparison of annotation files, as WFDB `bxb` does, as a development feature (#679), and axis labels in `plot_wfdb` (#670). - **Smaller fixes:** - integer overflow and precision in `find_peaks` and `normalize_bound`; - constant signals in `normalize_bound`; - multi-character custom annotation symbols; - format 61 signals read with `smooth_frames=False`; - skew written twice when rewriting records; - docstring examples, and more. This will be the first release published by `.github/workflows/publish.yml`, from the GitHub release, with provenance. ## Checks - `pytest -m "not network"`: 679 passed (4 skipped, the `bxb` comparison that needs WFDB installed), also with `--python 3.11 --resolution lowest-direct`. `pytest -m network`: 20 passed. - Ruff and the Sphinx HTML build with warnings as errors pass. - The wheel and source distribution build and pass `twine check`. They have `Version: 5.2.0` and include `wfdb/processing/beat_comparison.py`. - PyPI has no 5.2.0 release yet. <sub>@tompollard 🟥 red 🦥 sloth · aspen</sub>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #470.
rdannandAnnotation.apply_rangeincluded an annotation at samplesampto, whilerdrecordandrdsampreturn the samples before it. Annotations read with the same range as a signal could therefore be one sample past its end, and indexing the signal with them raised anIndexError. They now return the annotations beforesampto.This changes results for code that relies on the old behaviour, so it is for a minor release (5.2.0), and the changelog entry says how to get the old result (pass
sampto + 1). Nothing in wfdb itself callsrdannorapply_rangewithsampto.Testing
sampto, with and withoutsampfrom(the two code paths inrdann), forapply_range, and for the example in the issue. They fail onmain.pytest: all offline and network tests pass. Ruff and the docs build pass.@tompollard 🟥 red 🦥 sloth · aspen